import {legacy_createStore,applyMiddleware} from 'redux'
import thunk from 'redux-thunk'
import logger from 'redux-logger'
const initialState = {
    list:[],
    add:[]
}

const reducer= (state = initialState, { type, payload }:any) => {
    const newdata=JSON.parse(JSON.stringify(state))
  switch (type) {

  case 'get':
    newdata.list=payload
    return newdata
    case 'add':
      newdata.add.push(payload) 
      return newdata
  default:
    return newdata
  }
}

const store=legacy_createStore(reducer,applyMiddleware(thunk,logger))

export default store